package com.yc.blog.springmvc.jsp.ctr;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import com.yc.blog.springmvc.jsp.pojo.DemoResult1;

/**
 * 使用@RestController
 * 直接返回数据
 */
@RestController
public class DemoController3 {
	
	/**
	 * 增加@ResponseBody
	 * 直接返回字符串
	 * @return
	 */
	@RequestMapping("/c3-1")
	public String c1() {
		System.out.println("--------c3-1---------");
		
		return "success";
	}

	/**
	 * 增加@ResponseBody
	 * 直接返回对象，被自动转为json
	 * @param modelAndView
	 * @return
	 */
	@RequestMapping("/c3-2")
	public DemoResult1 c1(ModelAndView modelAndView) {
		System.out.println("--------c3-1---------");
		
		DemoResult1 dr = new DemoResult1("3aaaa1", "3bbbb1");
		
		return dr;
	}
}
